package com.meta.act.app.domain.tenant;

import com.google.common.collect.Lists;
import com.meta.act.entity.SysMenu;
import com.meta.act.app.tenant.entity.TenantMenuRelate;
import com.meta.framework.common.utils.SecurityUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * java类简单作用描述
 *
 * @Title:
 * @Package: com.meta.act.app.domain.tenant.
 * @Author: M.simple
 * @Remark: The modified content
 * @CreateDate: 2020/11/25 2:25 下午
 * @Version: v2.0
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class TenantMenuRelateDo extends TenantMenuRelate {

	public static List<TenantMenuRelateDo> of(List<SysMenu> sysMenuList, Long tenantId){

		List<TenantMenuRelateDo> tenantMenuRelateDos = Lists.newArrayList();
		sysMenuList.stream().forEach(x -> {
			TenantMenuRelateDo tenantMenuRelateDo = of(tenantId, x);

			tenantMenuRelateDos.add(tenantMenuRelateDo);
		});

		return tenantMenuRelateDos;
	}

	public static TenantMenuRelateDo of(Long tenantId, SysMenu sysMenu) {
		
		TenantMenuRelateDo tenantMenuRelateDo = new TenantMenuRelateDo();
		tenantMenuRelateDo.setMenuId(sysMenu.getMenuId());
		tenantMenuRelateDo.setTenantId(tenantId);
		tenantMenuRelateDo.setCreateBy(SecurityUtils.getUserId());
		return tenantMenuRelateDo;
	}

	;
}
